<?php
    session_start();
    ob_start();
    require("./config.php");
    require("./common_start.php");
    $id_sp=$_GET['p'];
    if($id_sp != "") {
        $sql = "select id,price from tbl_product where id in(".$id_sp.")";
        //Kiem tra id co trong csdl hay ko?
        $row = mysql_query($sql,$conn);
        $record = mysql_fetch_row($row);
        $num_row = mysql_num_rows($row);
        if($num_row == 1) {
            //session_register('cart');
            //Neu id nay co trong gio hang roi
            if(isset($_SESSION['cart'][$id_sp]) && isset($_SESSION['price'][$id_sp])) {
                //Tang so luong
                $_SESSION['cart'][$id_sp] ++;
                $_SESSION['price'][$id_sp] = $_SESSION['price'][$id_sp] * 2;
            } else {
                $_SESSION['cart'][$id_sp] = 1;
                $_SESSION['price'][$id_sp] = $record[1];
            }
        }
    }
    location("/khohangtot/home.htm");
?>
<?php
function location($url)
{?>
<script type="text/javascript">
window.history.go(-1);
//window.location = "<?=$url?>";
</script>
<?php }
?>